<template>
	<view
		:style="'background: url(' + imgData.vipBg + ') no-repeat;background-size: contain;height:' + systemInfo.screenHeight + 'px; background-attachment: fixed'">
		<u-navbar title=" " :autoBack="true" bgColor="transparent" leftIconColor="#fff" fixed></u-navbar>
		<template v-if="$userInfo.level == 5">
			<view class="p-30"
				:style="'background: url(' + imgData.settleHeader + ') no-repeat;background-size: contain;height:' + systemInfo.screenHeight + 'px;'">
				<u-scroll-list :indicator="false">
					<view class="tag" style="flex-direction: row;">
						<view class="tag-item" @click.stop="tagClick(item)" :class="{'active':tag_id == item.id}"
							v-for="(item,index) in tagData">
							{{item.name}}
						</view>
					</view>
				</u-scroll-list>
				<view class="box mt-30">
					<view :class="{'mt-30':index != 0}" v-for="(item,index) in list" v-if="!noData">
						<staff-img :item="item"></staff-img>
					</view>
					<template v-else>
						<u-empty mode="data">
						</u-empty>
					</template>
				</view>
			</view>
		</template>
		
		<u-overlay :show="overlayShow" @click="overlayShow = false">
			<view class="warp" @tap.stop>
				<image :src="vipimg" mode=""></image>
				<view @click="url1('/pages/mine/vip?current=4')" class="mt-30">
					<u-button :color="$u.color.color" shape="circle" text="开通至尊会员"
						:customStyle="{'width':'300rpx'}"></u-button>
				</view>
			</view>
		</u-overlay>
	</view>
</template>

<script>
	import {
		staffVipList,
		vipImg
	} from '@/common/api.js'
	import {
		mapState
	} from "vuex";
	import commonMixin from '@/mixins/common.js';
	export default {
		mixins: [commonMixin],
		data() {
			return {
				overlayShow: false,
				tag_id: 0,
				check_state: 0,
				is_share: 0,
				title: "",
				status: 'loading',
				list: [],
				noData: false,
				page: 1,
				total: 0,

				vipimg: ""
			}
		},
		computed: {
			...mapState(["tagData"]),
		},
		onLoad(e) {
			if (this.$userInfo.level != 5) {
				vipImg().then(res => {
					console.log('res', res);
					this.vipimg = res;
					this.overlayShow = false;
				})
			}else {
					this.init()
			}
		
		},
		methods: {
			url1(e) {
				uni.redirectTo({
					url:e
				})
			},
			tagClick(item) {
				this.tag_id = item.id
				this.init();
			},
			init() {
				this.status = "loading";
				this.list = [];
				this.page = 1;
				this.noData = false;
				this.getList();
			},
			getList() {
				let vm = this;
				let params = {
					'page': this.page,
					'limit': this.$u.config.limit,
					'tag_id': this.tag_id,
					'check_state': this.check_state,
					'is_share': this.is_share
				};
				staffVipList({
					params
				}).then(res => {
					console.log(res.length);
					if (res.rows.length != 0) {
						this.noData = false;
						this.list = res.rows;
						this.total = res.total;
						this.page++;
						this.status = "loadmore"
					} else {
						this.noData = true;
						this.status = "nomore"
					}
				}).catch(err => {
					vm.$refs.uToast.show({
						type: 'error',
						message: err.message,
						complete() {
							vm.loading = false;
						}
					})
				})
			},
			//上拉
			onPullDownRefresh() {
				this.status = "loading"
				this.init();
				setTimeout(function() {
					uni.stopPullDownRefresh();
				}, 500);
			},
			//下拉
			onReachBottom() {
				let vm = this;
				this.status = 'loading';
				//延时为了看效果
				setTimeout(() => {
					if (vm.page > Math.ceil(vm.total / this.$u.config.limit)) {
						this.status = 'nomore';
					} else {
						vm.getList();
					}
				}, 200)
			}
		}

	}
</script>
<style>
	page {
		background: #360602;
	}
</style>

<style lang="scss" scoped>
	.tag {
		display: flex;
		flex-direction: row;

		// justify-content: space-between;
		// margin-top: 30rpx;
		&-item {
			border: 1rpx solid #E6E6E6;
			padding: 10rpx 20rpx;
			margin-left: 10rpx;
			color: #575859;
			background-color: #fff;
			border-radius: 30rpx;
			font-size: 24rpx;
			width: 120rpx;
			text-align: center;
		}

		&-item:first-child {
			margin: 0;
		}
	}

	.active {
		color: #A11A0E;
		border-color: #A11A0E;
		background-color: transparent;
	}

	.warp {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		height: 100%;
	}

	.rect {
		width: 120px;
		height: 120px;
		background-color: #fff;
	}
</style>